﻿using System;
using System.Collections.ObjectModel;
using System.Net;
using System.Windows;

namespace SharepointUpload
{
    public class FormFields
    {
        private FormField field;
        private ObservableCollection<SPService.LookupValue> values;
        public FormField Field { get { return field; } set { field = value; } }
        public ObservableCollection<SPService.LookupValue> Values { get { return values; } set { values = value; } }
    }
    public class FormField
    {
        private string title;
        private Type fieldType = null;
        public string Name { get { return title; } set { title = value; } }
        public Type FieldType { get { return fieldType; } set { fieldType = value; } }
    }
    /* SPFieldTypes:
     * SPFieldBoolean
     * SPFieldChoice - drop down menu
     * SPFieldCurrency - double
     * SPFieldDateTime - DateTime
     * SPFieldLookup - var
     * SPFieldMultiChoice - Drop Down
     * SPFieldMultiColumn ?
     * SPFieldMultiLineText - string
     * SPFieldNumber - int
     * SPFieldRatingScale
     * SPFieldText - string
     * SPFieldUrl - string(url/title)
     * SPFieldUser - WSS User ID
     */
    public class FieldDefinition
    {
        public Type FieldType(SPService.FieldInfo field)
        {
            switch (field.Type)
            {
                case "Microsoft.SharePoint.SPFieldLookup":
                    return typeof(SPLookup);
                    break;
                case "Microsoft.SharePoint.SPFieldBoolean":
                    return typeof(bool);
                    break;
                case "Microsoft.SharePoint.SPFieldChoice":
                    return typeof(SPLookup);
                    break;
                case "Microsoft.SharePoint.SPFieldCurrency":
                    return typeof(double);
                    break;
                case "Microsoft.SharePoint.SPFieldDateTime":
                    return typeof(DateTime);
                    break;
                case "Microsoft.SharePoint.SPFieldMultiChoice":
                    return null;
                    break;
                case "Microsoft.SharePoint.SPFieldMultiColumn":
                    return null;
                    break;
                case "Microsoft.SharePoint.SPFieldLineText":
                    return typeof(string);
                    break;
                case "Microsoft.SharePoint.SPFieldNumber":
                    return typeof(int);
                    break;
                case "Microsoft.SharePoint.SPFieldRatingScale":
                    return null;
                    break;
                case "Microsoft.SharePoint.SPFieldUrl":
                    return typeof(SPLookup);
                    break;
                case "Microsoft.SharePoint.SPFieldText":
                    return typeof(string);
                    break;
                case "Microsoft.SharePoint.SPFieldUser":
                    return typeof(SPLookup);
                    break;
            }
            return null;
        }
    }

    public class SPLookup
    {
        private string intValue;
        private string title;
        public string Value { get { return intValue; } set { intValue = value; } }
        public string Title { get { return title; } set { title = value; } }
    }
}
